<?php

App::uses('AppController', 'Controller');

class UsersController extends AppController {

    public $layout = 'login';

    public $components = array( 'Auth' );

    public function login() {
        if ($this->Auth->user('id')) {
            $this->redirect('/admin');
        }
        //debug($this->Auth->password('3latar4celest@'));
        $data = $this->data;
        if (! empty($data)) {
            if ($this->Auth->login()) {
                $this->redirect($this->Auth->redirectUrl());
            } else {
                $this->setFlash('Prijava nije uspela');
            }
        }
    }
    
    public function logout() {
        $this->redirect($this->Auth->logout());
    }
}

?>
